package com.chen.order.system.ordersystem.controller;

import com.chen.order.system.ordersystem.entity.OrderEntity;
import com.chen.order.system.ordersystem.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单接口
 * @author :master
 */
@RestController
@RefreshScope
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService service;

    @RequestMapping("/addOrder")
    public String addOrder(@RequestBody OrderEntity entity) {
        try {
            service.addOrder(entity);
            return "新增订单成功";
        }catch (Exception e) {
            return "新增订单失败";
        }

    }


    @RequestMapping("/updateOrder")
    public String updateOrder(@RequestBody OrderEntity entity) {
        try {
            service.addOrder(entity);
            return "修改订单成功";
        }catch (Exception e) {
            return "修改订单失败";
        }

    }
}
